web_socket_server_sendmessage Function
Syntax
Arguments
- messageJSONCharacter
A JSON string that contains the data to send. The JSON should be in the format expected by the client.
Returns
- resultPointer
Returns a dot variable with the following properties:
- errorLogical
Indicates whether or not an error occurred.
- errorTextCharacter
If an error occurred, contains information about the error. errorText will be blank if no error occurred.
Description
Send a message to the web-sockets server. All clients that are listening to the web-sockets server will receive the message and the webSocketOnMessage client side event in each client will fire.
Discussion
The sends a message to the web-sockets server. The message is sent to all clients that are listening for messages.
The message must be defined as a JSON string. The JSON format is dictated by the client(s) listening for the message. For example, if the client is expecting to receive a text string in a property called "newMessage", you must include this property in your JSON string.
dim pm as p pm.newMessage = "Hello!" dim json as c messageJSON = json_generate(pm) callResult = web_socket_server_sendMessage(messageJSON)
If messageJSON is not a JSON string, you may see the following error message on the client when a message is sent:
Received a message that was not in correct format. Messages must be JSON strings
web_socket_server_sendMessage() is not supported in Working Preview.
See Also